﻿using SqlSugar;
using System.Data;
using DbType = SqlSugar.DbType;

namespace AspNetCoreSseServer
{
    public class DbContext
    {
        //创建数据库对象 (用法和EF Dappper一样通过new保证线程安全)
        public static SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
        {
            ConnectionString = "Data Source=10.10.172.46\\NEWMSSQL;Initial Catalog=ZN2401901;User ID=sa;Password=126.com;Encrypt=True;TrustServerCertificate=True;",
            DbType = DbType.SqlServer,
            IsAutoCloseConnection = true
        },
        db => {

            db.Aop.OnLogExecuting = (sql, pars) =>
            {

                //获取原生SQL推荐 5.1.4.63  性能OK
                Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));
            };

        });
    }
}
